const { Sequelize, Model } = require('sequelize');
// const { Article } = require('./article');
// const { User } = require('./user');

const sequelize = new Sequelize('sequelize_demo03', 'root', 'root', {
  host: 'localhost',
  dialect: 'mysql',
})

;(async () => {
  try {
    await sequelize.authenticate();
    console.log('Connection has been established successfully.')
  } catch (error) {
    console.error('Unable to connect to the database:', error)
  }
  await sequelize.sync({ alter: true })
  // User.hasMany(Article, { as: 'article' })
  // Article.belongsTo(User, { as: 'user', foreignKey: 'uid' })
})()

module.exports = {
  sequelize
}